<template>
	<view>
		<u-sticky bgColor="#6492FF" offsetTop=0 customNavHeight=0>
			<navbox title="修改密码"></navbox>
		</u-sticky>
		<view class="con">
			<view class="con__form">
				<view class="con__form__item">
					<image src="/static/img/index/ic_login_phone.png" class="con__form__item__icon" mode=""></image>
					<input placeholder="请输入新密码" v-model="iCustomer.password" type="password"
						class="con__form__item__inp" />
				</view>
				<view class="con__form__item">
					<image src="/static/img/index/ic_login_psw.png" class="con__form__item__icon" mode=""></image>
					<input placeholder="请再次输入新密码" v-model="iCustomer.repassword" type="password"
						class="con__form__item__inp" />
				</view>
				<view class="con__form__btn">
					<u-button text="修改密码" :loading='loading' color="#6492FF" @click="submit" shape='circle'></u-button>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {customeredit} from '@/api/user.js'
	export default {
		data() {
			return {
				tips: '',
				// refCode: null,
				seconds: 60,
				iCustomer: {
					password:'',
					repassword:''
				},
				loading: false,
				type:0
			};
		},
		methods:{
			codeChange(text) {
				this.tips = text;
			},
			submit(){
				let {password,repassword} = this.iCustomer
				if (!password) {
					this.$u.toast('请输入密码')
					return
				}
				if (!repassword) {
					this.$u.toast('请再次输入密码')
					return
				}
				if(password!=repassword){
					this.$u.toast('两次密码输入不一致')
					return
				}
				this.loading=true
				customeredit({password}).then(res=>{
					this.loading=false
					if(res.data.code==200){
						this.$u.toast('修改成功')
						setTimeout(()=>{
							
							uni.navigateBack()
						},2000)
					}else{
						this.$u.toast(res.data.msg)
					}
				})
			},
			end() {
				// uni.$u.toast('倒计时结束');
			},
			start() {
				// uni.$u.toast('倒计时开始');
			},
		},
		onLoad(option) {
			this.type=option.type
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.con {
		padding: 10% 0 0;
		display: flex;
		flex-direction: column;
		align-items: center;

		&__logo {
			width: 160rpx;
			height: 160rpx;
		}

		&__form {
			padding: 0 75rpx;
			width: 600rpx;
			font-size: 26rpx;
			line-height: 26rpx;

			&__item {
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid rgba(205, 205, 205, .8);
				padding: 20rpx 0;

				&__icon {
					width: 40rpx;
					height: 40rpx;
					margin-right: 10rpx;
				}

				&__inp {
					font-size: 26rpx;
					flex: 1;
				}
			}

			&__ts {
				color: #6492ff;
				margin-top: 40rpx;
			}

			&__btn {
				padding: 50rpx 50rpx 30rpx;
			}

			&__check {
				margin-right: 6rpx;

				&__icon {
					width: 30rpx;
					height: 30rpx;
				}
			}

		}
	}
</style>